package flc.ast.adapter;

import android.view.View;
import android.widget.ImageView;

import com.blankj.utilcode.util.FileUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkEmptyProvider;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.media.bean.AudioBean;

public class SelMusicAdapter extends StkProviderMultiAdapter<AudioBean> {


    public SelMusicAdapter() {
        addItemProvider(new StkEmptyProvider<>(321));
        addItemProvider(new SelMusicProvider());
    }

    private class SelMusicProvider extends com.chad.library.adapter.base.provider.BaseItemProvider<AudioBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_sel_music;
        }

        @Override
        public void convert(@NotNull BaseViewHolder baseViewHolder, AudioBean bean) {
            Glide.with(baseViewHolder.itemView).load(bean.getPath()).into((ImageView) baseViewHolder.getView(R.id.ivSelMusicItemImage));
            baseViewHolder.setText(R.id.tvSelMusicItemName, bean.getName());
            baseViewHolder.setText(R.id.tvSelMusicItemDate, TimeUtils.millis2String(bean.getDateModified(), "yyyy.MM.dd"));
            if (bean.isSelected()) {
                baseViewHolder.getView(R.id.llMusicSelItemSel).setVisibility(View.VISIBLE);
            } else {
                baseViewHolder.getView(R.id.llMusicSelItemSel).setVisibility(View.GONE);
            }
        }
    }

}
